<?php
class Control_ServerList_addServerList {
 	function addServerList() {
 		$action = MooForm::request('action');
 		if($action == 1) {
 			$game 		= MooForm::request('game');
 			// 中文转换英文 game
 			$game = MooObj::get('Game')->transportGame($game);
 			$platform 	= MooForm::request('platform');
 			$serverListName = MooForm::request('serverListName');
 			$ftpAddress = MooForm::request('ftpAddress');
 			$ftpUser 	= MooForm::request('ftpUser');
 			$ftpPwd 	= MooForm::request('ftpPwd');
 			$serverListDao = MooDao::get('Serverlist');
 			
 			$serverListObj = $serverListDao->load(array(
 				's_game' => $game,
 				's_platform' => $platform,
 				's_filename' => $serverListName,
 			));
 			
 			if(!empty($serverListObj)) {
 				$returnData['code'] = 3;
 				$returnData['msg'] = '该名称已存在';
 				exit(MooJson::encode($returnData));
 			}
 			
 			$serverListDao->setData('s_game', $game);
 			$serverListDao->setData('s_platform', $platform);
 			$serverListDao->setData('s_filename', $serverListName);
 			$serverListDao->setData('s_ftpaddress', $ftpAddress);
 			$serverListDao->setData('s_ftpuser', $ftpUser);
 			$serverListDao->setData('s_ftppwd', $ftpPwd);
 			$serverListDao->setData('s_serverlist', "");
 			
 			if($serverListDao->insert()) {
 				$returnData['code'] = 1;
 				$returnData['msg'] = '添加成功';
 				exit(MooJson::encode($returnData));
 			} else {
 				$returnData['code'] = 2;
 				$returnData['msg'] = '添加失败';
 				exit(MooJson::encode($returnData));
 			}
 			
 		} else {
 			MooView::render("addServerList");
 		}
 		
	}
	
}

